{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>订单管理</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-13">
                    <form name="points_index" class="form-search" method="get" action="{:url('index')}">
                        <div class="col-sm-4" id="data_5">
                            <div class="input-daterange input-group" id="datepicker">
                                <input type="text" class="input-mini form-control" placeholder="下单时间" name="add_time" id="start" value="{$Request.param.add_time}"/>
                                <span class="input-group-addon" style="background-color: #fff !important;border: none !important;">&nbsp;</span>
                                <input type="text" class="input-mini form-control" placeholder="支付时间" name="pay_time" id="end" value="{$Request.param.pay_time}" />
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="col-sm-12 input-group">
                                <input type="text" class="input-mini form-control" placeholder="订单编号" name="order_sn" value="{$Request.param.order_sn}"/>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="col-sm-12 input-group">
                                <input type="text" class="input-mini form-control" placeholder="用户名" name="user_name" value="{$Request.param.user_name}"/>
                            </div>
                        </div>					
                        <div class="col-sm-3">
                            <div class="input-group">
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                                </span>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th>ID</th>
                                <th width="10%">订单编号</th>
                                <th width="5%">外部订单号</th>
                                <th width="10%">用户名</th>
                                <th width="8%">订单状态</th>
                                <th width="8%">支付状态</th>
                                <th width="10%">支付名称</th>
                                <th width="5%">订单金额</th>
                                <th width="10%">备注</th>
                                <th width="12%">下单时间</th>
                                <th width="12%">支付时间</th>
                                <th width="20%">操作</th>
                            </tr>
                        </thead>
                        <tbody id="article_list">
                            {foreach name="lists" item="vo"}
                                <tr class="long-td">
                                    <td>{$vo.order_id}</td>
                                    <td>{$vo.order_sn}</td>
                                    <td>{$vo.out_trade_no}</td>      
                                    <td>{$vo.user_name}</td>  
                                    <td>
                                    {if condition="$vo['order_status'] eq -1"}支付失败
                                    {elseif condition="$vo['order_status'] eq 0"}待支付
                                    {elseif condition="$vo['order_status'] eq 1"}已支付
                                    {elseif condition="$vo['order_status'] eq 2"}交易完成
                                    {else}取消订单 
                                    {/if}
                                    </td>
                                    <td>
                                    {if condition="$vo['pay_status'] eq -1"}支付失败
                                    {elseif condition="$vo['pay_status'] eq 0"}待支付
                                    {elseif condition="$vo['pay_status'] eq 1"}已支付
                                    {elseif condition="$vo['pay_status'] eq 2"}交易完成
                                    {else}取消订单 
                                    {/if}
                                    </td>
                                    <td>{$vo.pay_name}</td>
                                    <td>{$vo.order_amount}</td>
                                    <td>{$vo.mark}</td>
                                    <td>{$vo.add_time|date="Y-m-d H:i:s",###}</td>          
                                    <td>{$vo.pay_time|date="Y-m-d H:i:s",###}</td>
                                    <td>
                                        <a href="javascript:;" onclick="del_order({$vo.order_id})" class="btn btn-danger btn-xs">
                                            <i class="fa fa-trash-o"></i> 删除</a>   
                                    </td>
                                </tr>
                            {/foreach}
                        </tbody>
                    </table>
                </div>
                <!-- 分页 -->
                <div id="Pages">  {$page} </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}


<script type="text/javascript">

function del_order(id){
    layer.confirm('确认删除此数据?', {icon: 3, title:'提示'}, function(index){
        //do something
        $.getJSON("{:url('del_order')}", {'id' : id}, function(res){
            if(res.code == 1){
                layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
                    window.location.href="{:url('order/index')}";
                });               
            }else{
                layer.msg(res.msg,{icon:0,time:1500,shade: 0.1});
            }
        });

        layer.close(index);
    })

}

$('#data_5 .input-daterange').datepicker({
    keyboardNavigation: false,
    forceParse: false,
    autoclose: true
});
</script>
</body>
</html>